package com.nongye.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nongye.common.annotation.Log;
import com.nongye.common.core.controller.BaseController;
import com.nongye.common.core.domain.AjaxResult;
import com.nongye.common.enums.BusinessType;
import com.nongye.system.domain.MuChangData;
import com.nongye.system.service.IMuChangDataService;
import com.nongye.common.utils.poi.ExcelUtil;
import com.nongye.common.core.page.TableDataInfo;

/**
 * 牧场数据Controller
 * 
 * @author nongye
 * @date 2023-10-10
 */
@Api(value = "牧场数据",tags = "牧场数据")
@RestController
@RequestMapping("/system/muchangdata")
public class MuChangDataController extends BaseController
{
    @Autowired
    private IMuChangDataService muChangDataService;

    /**
     * 查询牧场数据列表
     */
    @ApiOperation(value = "查询牧场数据列表")
    @GetMapping("/list")
    public TableDataInfo list(MuChangData muChangData)
    {
        startPage();
        List<MuChangData> list = muChangDataService.selectMuChangDataList(muChangData);
        return getDataTable(list);
    }

    /**
     * 导出牧场数据列表
     */
    @ApiOperation(value = "导出牧场数据列表")
    @Log(title = "牧场数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MuChangData muChangData)
    {
        List<MuChangData> list = muChangDataService.selectMuChangDataList(muChangData);
        ExcelUtil<MuChangData> util = new ExcelUtil<MuChangData>(MuChangData.class);
        util.exportExcel(response, list, "牧场数据数据");
    }

    /**
     * 获取牧场数据详细信息
     */
    @ApiOperation(value = "获取牧场数据详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(muChangDataService.selectMuChangDataById(id));
    }

    /**
     * 新增牧场数据
     */
    @ApiOperation(value = "新增牧场数据")
    @Log(title = "牧场数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MuChangData muChangData)
    {
        return toAjax(muChangDataService.insertMuChangData(muChangData));
    }

    /**
     * 修改牧场数据
     */
    @ApiOperation(value = "修改牧场数据")
    @Log(title = "牧场数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MuChangData muChangData)
    {
        return toAjax(muChangDataService.updateMuChangData(muChangData));
    }

    /**
     * 删除牧场数据
     */
    @ApiOperation(value = "删除牧场数据")
    @Log(title = "牧场数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(muChangDataService.deleteMuChangDataByIds(ids));
    }
}
